#!/bin/sh

forceUnMountDevice() {
    local aDevice=$1 ; shift

    [ -r /proc/mounts ] || return 0
    [ -x /bin/umount ] || return 0

    local vDevice
    local vMountpoint
    local vFsType
    local vOptions
    local vDump
    local vOrder

    while read vDevice vMountpoint vFsType vOptions vDump vOrder ; do
        if [ "${vDevice}" = "${aDevice}" ] ; then
            /bin/umount -fl ${vMountpoint}
        fi
    done < /proc/mounts
    return 0
}

if [[ "${HALD_ACTION}" = "remove" ]] ; then
    forceUnMountDevice ${HAL_PROP_BLOCK_DEVICE}
    sleep .5
fi
exec /usr/sbin/fstab-sync
